package com.yubest.demo;

import cn.hutool.core.util.StrUtil;
import com.yubest.demo.handler.FileType;
import com.yubest.demo.handler.Handler;
import com.yubest.demo.handler.HandlerBuilder;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.File;

/**
 * @Author hweiyu
 * @Description
 * @Date 2021/8/12 9:38
 */
@Data
@Accessors(chain = true)
public class CompressAnalysis {

    private String filePath;

    public String analysis() {
        if (StrUtil.isBlank(getFilePath())) {
            System.out.println("======文件路径为空");
            return null;
        }
        File file = new File(getFilePath());
        if (!file.exists() || !file.isFile()) {
            System.out.println("======文件不存在或不是文件");
            return null;
        }
        Handler handler = new HandlerBuilder()
                .setPath(getFilePath())
                .getHandler();
        return handler.exec(getFilePath());
    }

    public static void main(String[] args) {
        System.out.println(new CompressAnalysis()
                .setFilePath("D:\\BaiduNetdiskDownload\\PS教程\\PS2020基础入门到精通课程\\PS2020基础入门到精通课程.zip")
                .analysis());
    }
}
